package com.zhizihua.content.config;

import com.baomidou.mybatisplus.annotation.DbType;
import com.baomidou.mybatisplus.extension.plugins.MybatisPlusInterceptor;
import com.baomidou.mybatisplus.extension.plugins.inner.PaginationInnerInterceptor;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @description: MybatisPlus配置
 * @author: zhizihua
 * @Email 2876290193@qq.com
 * @date: 2025/5/6 0:18
 */

@Configuration
@MapperScan("com.zhizihua.content.mapper")
public class MybatisPlusConfig {

    /**
     * 定义分页拦截器
     */
    @Bean
    public MybatisPlusInterceptor mybatisPlusInterceptor() {
        // 创建MybatisPlus拦截器实例
        MybatisPlusInterceptor interceptor = new MybatisPlusInterceptor();
        // 为拦截器添加内置的分页拦截器，指定数据库类型为MySQL
        interceptor.addInnerInterceptor(new PaginationInnerInterceptor(DbType.MYSQL));
        // 返回配置好分页拦截器的MybatisPlus拦截器实例
        return interceptor;

    }
}
